﻿@model  PagingDataSet<User>
@{
    Dictionary<long, IEnumerable<long>> followedUserIdDic = ViewData["followedUserIdDic"] as Dictionary<long, IEnumerable<long>>;
    Dictionary<long, User> followedUserDic = ViewData["followedUserDic"] as Dictionary<long, User>;
    IUser currentUser = UserContext.CurrentUser;
}

@foreach (var user in Model)
{
    string gender = "";

    if (user.Profile != null)
    {
        if (user.Profile.Gender == GenderType.Male)
        {
            gender = "tn-icon tn-smallicon-male";
        }
        else if (user.Profile.Gender == GenderType.FeMale)
        {
            gender = "tn-icon tn-smallicon-female";
        }
    }
    <li class="tn-list-item tn-helper-clearfix tn-border-gray tn-border-bottom tn-border-dashed">
        <div class="tn-list-item-area-left">
            @Html.ShowUserAvatar(user, AvatarSizeType.Medium, true, HyperLinkTarget._blank)
        </div>
        <div class="tn-list-item-area-main">
            <div class="tn-list-item-row tn-helper-clearfix">
                                    @if (currentUser != null && !currentUser.IsFollowed(user.UserId))
                {
                    <div class="tnc-relationship" id="followedDiv">
                        @Html.FollowUser(user.UserId, "加收藏", followButtonType: FollowButtonTypes.Link)
                    </div>
                }
                <div class="tnc-user-notename">
                    <a href="@SiteUrls.Instance().SpaceHome(user.UserName)" class="tn-user-name" target="_blank">@user.DisplayName</a>
                    @Html.IdentificationType(user.UserId)
                </div>
            </div>
            <div class="tnc-userinfo-content tn-helper-clearfix">
                <div class="tnc-userinfo-item">
                    <div class="tn-list-item-row">
                        <div class="tn-location">
                            <span title='@if (user.Profile.Gender == GenderType.Male)
                                         {<text>男</text>}
                                         else
                                         {<text>女</text>}' class="@gender"></span>
                            @if (user.Profile != null && !string.IsNullOrEmpty(user.Profile.NowAreaCode))
                            {   
                                @Formatter.FormatArea(user.Profile.NowAreaCode, false)
                            }
                        </div>
                    </div>
                    <div class="tn-list-item-row tnc-usernums">
                        <span>收藏 <a href="@SiteUrls.Instance().ListFollowedUsers(user.UserName)" target="_blank"><strong>@user.FollowedCount</strong></a></span>
                        <span class="tn-spacer tn-text-note">|</span> <span>粉丝 <a href="@SiteUrls.Instance().ListFollowers(user.UserName)" target="_blank"><strong>@user.FollowerCount</strong></a></span>
                        <span class="tn-spacer tn-text-note">|</span> <span>内容数 <strong>@user.ContentCount</strong></span>
                    </div>
                </div>
            </div>
            <div class="tn-list-item-row">
                <div class="tn-widget tn-bubble tn-bubble-arrow-top">
                    <div class="tn-bubble-arrow"><b class="tn-arrow-b1 tn-border-gray"></b><b class="tn-arrow-b2 tn-widget-bubble"></b></div>
                    <div class="tn-bubble-content tn-border-gray tn-corner-all">
                        @{
                            IEnumerable<long> followedUserIds = followedUserIdDic[user.UserId];
                            int followedUserCount = followedUserIds.Count<long>();
                        }
                        <p>
                            <a href="@SiteUrls.Instance().SpaceHomeMore(user.UserName, 2)">@followedUserCount</a><text>个共同收藏人：</text>
                            @foreach (long followedUserId in followedUserIds.Take(10))
                            {
                                User followedUser = followedUserDic[followedUserId];

                                <a href="@SiteUrls.Instance().SpaceHome(followedUser.UserName)" target="_blank">@followedUser.DisplayName</a>
                            }
                            @if (followedUserCount > 10)
                            {
                                @:...
                                                }
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </li>
}
@Html.Hidden("pageCount", @Model.PageCount)